package org.marketlive.system.encryption;

/**
 * Interface for decryption methods.
 */

/*
(C) Copyright MarketLive. 2006. All rights reserved.
MarketLive is a trademark of MarketLive, Inc.
Warning: This computer program is protected by copyright law and international treaties.
Unauthorized reproduction or distribution of this program, or any portion of it, may result
in severe civil and criminal penalties, and will be prosecuted to the maximum extent
possible under the law.
*/

public interface IDecryptor {
    /**
     * Init method to setup decryption.
     */
    void init();

    /**
     * Decrypt the encrypted input string using security provider specific decryption and return the decrypted string.
     * @param encryptedString the encrypted string to decipher.
     * @return returns an unencrypted string.
     * @throws DecryptionException
     */
    String decrypt(String encryptedString) throws DecryptionException;

    /**
     * Decrypt the encrypted input string using security provider specific decryption and return the decrypted string.
     * @param keyCode the keyCode to lookup the private key from the KeyStore table.
     * @param encryptedString the encrypted string to decipher.
     * @return returns an unencrypted string.
     * @throws DecryptionException
     */
    String decrypt(String keyCode, String encryptedString) throws DecryptionException;
    
    /**
     * Compares two encrypted strings and returns true if they are equal.  Requires decryption to do this.
     * @param encryptedString1  the first encrypted string to compare.
     * @param encryptedString2 the second encrypted string to compare.
     * @return returns true if the two values decrypt to the same value.
     */
    public boolean compare(String encryptedString1, String encryptedString2) throws DecryptionException;    

}
